package com.huawei.appgallery.forum.section.impl;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.forum.base.ui.ForumActivity;
import com.huawei.appgallery.forum.section.actionbar.SectionActionBar;
import com.huawei.appgallery.forum.section.api.ISectionDetailActivityProtocol;
import com.huawei.appgallery.forum.section.api.ISectionDetailActivityResult;
import com.huawei.appgallery.forum.section.fragment.ForumSectionDetailFragment;
import com.huawei.appgallery.forum.section.fragment.ForumSectionDetailFragment.d;
import com.huawei.appgallery.forum.section.view.widget.tips.BubbleLayout;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.BaseListFragment.c;
import com.huawei.hmf.annotation.ActivityDefine;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import o.ayw;
import o.azb;
import o.bqx;
import o.cab;
import o.cab.e;
import o.cab.i;
import o.cab.j;
import o.cac;
import o.cad;
import o.cae;
import o.cau;
import o.cav;
import o.cbe;
import o.cgv;
import o.cia;
import o.dof;
import o.fiv;
import o.FragmentTransaction;

@ActivityDefine(alias = "section_detail_activity", protocol = ISectionDetailActivityProtocol.class, result = ISectionDetailActivityResult.class)
public class ForumSectionDetailActivity extends ForumActivity implements d, cav, c, OnClickListener {
    private SectionActionBar ʻॱ;
    private LinearLayout ʽॱ;
    private ActionBar ʾ;
    private Map<Integer, cia> ʿ = new HashMap();
    private fiv ˈ = fiv.ॱ(this);
    private int ˉ = -1;
    private TextView ˊˊ;
    private int ˋˊ = -1;
    private int ˋॱ;
    private int ͺ;
    private String ॱˊ;
    private String ॱˋ;
    private String ॱˎ;
    private boolean ᐝॱ;

    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        cgv.ˋ(this, b.ˏ, b.ˊ);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(b.ˊ));
        setContentView(i.ॱˊ);
        this.ʾ = getActionBar();
        if (this.ʾ != null) {
            this.ʾ.hide();
        }
        this.ʽॱ = (LinearLayout) findViewById(e.ˌ);
        azb.ˏ(this.ʽॱ);
        this.ʻॱ = (SectionActionBar) findViewById(e.ʽॱ);
        this.ʽॱ.findViewById(e.ˋ).setOnClickListener(this);
        this.ˊˊ = (TextView) findViewById(e.ʹ);
        Object ab_ = ab_();
        if (ab_ instanceof Map) {
            this.ʿ = (Map) ab_;
        }
        if (bundle == null) {
            ᐝ();
            ˋ(getString(j.ˏ));
            ͺ();
            return;
        }
        this.ॱˊ = bundle.getString("save_bundle_key_uri");
        this.ᐝॱ = bundle.getBoolean("save_bundle_key_from_buoy");
        this.ͺ = bundle.getInt("save_bundle_key_kind_id");
        String string = bundle.getString("save_bundle_key_title");
        if (string != null) {
            ˋ(string);
        }
    }

    private void ˋ(String str) {
        this.ˊˊ.setText(str);
    }

    private void ᐝ() {
        ISectionDetailActivityProtocol iSectionDetailActivityProtocol = (ISectionDetailActivityProtocol) this.ˈ.ॱ();
        this.ॱˊ = iSectionDetailActivityProtocol.getUri();
        this.ˋॱ = iSectionDetailActivityProtocol.getSectionId();
        this.ͺ = iSectionDetailActivityProtocol.getKindId();
        this.ᐝॱ = iSectionDetailActivityProtocol.getFromBuoy();
        this.ॱˎ = iSectionDetailActivityProtocol.getAppId();
        this.ॱˋ = iSectionDetailActivityProtocol.getDomainId();
        if (dof.ॱ(this.ॱˊ)) {
            this.ॱˊ = "forum|forum_detail|" + this.ˋॱ;
        } else {
            try {
                this.ˋॱ = Integer.parseInt(new cau().ˎ(this.ॱˊ));
            } catch (Exception e) {
                bqx.ˋ("ForumSectionDetailActivity", "parse sectionId error");
            }
        }
        bqx.ˏ("ForumSectionDetailActivity", "uri:" + this.ॱˊ + " ;kindId:" + this.ͺ + " ;fromBuoy:" + this.ᐝॱ);
    }

    private void ͺ() {
        try {
            Fragment forumSectionDetailFragment = new ForumSectionDetailFragment();
            Bundle bundle = new Bundle();
            bundle.putString("key_uri", this.ॱˊ);
            bundle.putString("key_domainid", this.ॱˋ);
            bundle.putString("key_appid", this.ॱˎ);
            forumSectionDetailFragment.ʼ(bundle);
            FragmentTransaction ˊ = ˏॱ().ˊ();
            ˊ.ˏ(e.ॱˊ, forumSectionDetailFragment, "ForumSectionDetailActivity");
            ˊ.ˋ();
        } catch (Exception e) {
            bqx.ˋ("ForumSectionDetailActivity", "showSectionDetailFragment Exception");
        }
    }

    public void ˏ(String str, int i) {
        this.ʽॱ.setVisibility(8);
        ˎ(str);
        ˎ(i);
        if (this.ˋˊ > 0 && this.ˉ > 0) {
            ˎ(this.ˋˊ, this.ˉ);
        }
    }

    public void ˊ(String str) {
        ˋ(str);
    }

    private void ˎ(String str) {
        if (this.ʾ != null) {
            this.ʾ.hide();
        }
        if (str != null) {
            this.ʻॱ.setTitle(str);
        }
        this.ʻॱ.setVisibility(0);
        if (VERSION.SDK_INT >= 21) {
            Window window = getWindow();
            ayw.ˏ(this, 16908290, null, false);
            cgv.ˋ(window);
            if (cgv.ˎ()) {
                cgv.ˏ(window, 1);
            } else {
                window.setStatusBarColor(-16777216);
            }
        }
        View findViewById = getWindow().getDecorView().findViewById(16908335);
        if (findViewById != null) {
            findViewById.setVisibility(8);
        }
    }

    private void ˎ(int i) {
        List<cae> ˋ = cad.ˋ().ˋ(this.ʻॱ.ˎ(), this.ᐝॱ, this.ͺ, i);
        if (ˋ != null && ˋ.size() > 0) {
            for (cae o_cae : ˋ) {
                if (o_cae instanceof cac) {
                    ˎ(o_cae.ᐝ());
                    return;
                }
            }
        }
    }

    private void ˎ(View view) {
        cbe ˊ = new cbe.c().ˏ((Activity) this).ˏ("tips_name_game_icon").ˋ(getResources().getString(j.ˊॱ)).ˊ();
        BubbleLayout ॱ = ˊ.ॱ((Activity) this);
        if (ॱ != null && view != null) {
            ॱ.measure(0, 0);
            int measuredWidth = ॱ.getMeasuredWidth();
            view.measure(0, 0);
            int dimensionPixelSize = measuredWidth - getResources().getDimensionPixelSize(cab.c.ʼ);
            measuredWidth = -((measuredWidth - (view.getMeasuredWidth() / 2)) - getResources().getDimensionPixelSize(cab.c.ʼ));
            int dimensionPixelSize2 = getResources().getDimensionPixelSize(cab.c.ˊ);
            ˊ.ˊ(dimensionPixelSize);
            ˊ.ˊ(view, measuredWidth, dimensionPixelSize2, 80);
        }
    }

    public void ˎ(int i, int i2) {
        if (this.ʻॱ != null) {
            this.ˋˊ = i;
            this.ˉ = i2;
            this.ʻॱ.ˋ(i, i2);
        }
    }

    public cia ॱ(int i) {
        return (cia) this.ʿ.get(Integer.valueOf(i));
    }

    public void ˋ(int i, cia o_cia) {
        bqx.ˊ("ForumSectionDetailActivity", "set Cache Provider:" + i);
        this.ʿ.put(Integer.valueOf(i), o_cia);
    }

    public Object T_() {
        return this.ʿ;
    }

    public void onSaveInstanceState(Bundle bundle) {
        bundle.putString("save_bundle_key_uri", this.ॱˊ);
        bundle.putString("save_bundle_key_title", this.ˊˊ.getText().toString());
        bundle.putBoolean("save_bundle_key_from_buoy", this.ᐝॱ);
        bundle.putInt("save_bundle_key_kind_id", this.ͺ);
        bundle.putString("save_bundle_key_appid", this.ॱˎ);
        bundle.putString("save_bundle_key_domainid", this.ॱˋ);
        super.onSaveInstanceState(bundle);
    }

    public void onClick(View view) {
        if (view.getId() == e.ˋ) {
            finish();
        }
    }

    public void onDestroy() {
        if (this.ʻॱ != null) {
            this.ʻॱ.ˊ();
        }
        super.onDestroy();
    }
}
